<?php
require_once('../../config.php');
Doctrine::loadModels('../../models');

if( $_REQUEST["item_id"])
{
	$item_id = strip_tags($_REQUEST["item_id"]);
    $item_name  = strip_tags($_REQUEST["item_name"]);
    $category_id = strip_tags($_REQUEST["category_id"]);
	$item_desc = strip_tags($_REQUEST["item_desc"]);
	$item_value = strip_tags($_REQUEST["item_value"]);

	$db_query = sprintf("UPDATE lk_glossary 
								SET item_name='".$item_name."',
								item_desc='".$item_desc."',
								item_value='".$item_value."',
								category_id='".$category_id."' 
						WHERE item_id='".$item_id."'");
 
 	//file_put_contents  ( "update_statement.txt", $db_query);   
 
 	$result = mysql_query($db_query);
    	if (!$result) {
        		die('invalid query');    // . mysql_error());
    		}
}

/* Using Doctrine need to find out why this won't update
      	$q->update('LkGlossary l')
        	->set('l.item_value', $item_value)
			->set('l.category_id', $category_id)
			->set('l.item_name','?',"'".$item_name."'")
			->set('l.item_desc','?',"'".$item_desc."'")                   
         	->where('l.item_id = '.$item_id);

        file_put_contents  ( "update_statement.txt", $q);
       
        $rows =$q->execute();   
	
	print $rows; // the number of affected rows
    
*/

mysql_free_result( $result )

?>